/********************************************************************************
 ***                                                                          *** 
 ********************************************************************************
 *                                                                              * 
 *           Prject Name : MEMORIA                                              * 
 *                                                                              * 
 *             File Name : cardlist.h                                           * 
 *                                                                              * 
 *            Programmer : LBW                                                  * 
 *                                                                              * 
 *            Start Date : 2020/12/26                                           * 
 *                                                                              * 
 *           Last Update : 2020/12/26  [LBW]                                    * 
 *                                                                              * 
 *------------------------------------------------------------------------------*
 * Functions:                                                                   * 
 *==============================================================================*/

#ifndef CARDLIST_H
#define CARDLIST_H

#include "parameter.h"
#include <QWidget>

class QVBoxLayout;
class Card;
class EditableCard;
class CardList : public QWidget
{
	Q_OBJECT
public:
	CardList(const QString &dbName,QWidget *parent = 0);
	int getCardSum() const;
signals:
	void lockPlease(int runMode);
	void cardSumChanged(int cardSum,int thisPageBegin);
private slots:
	//from mainwindow
	void testButton_clicked();
	void editButton_clicked();	
	void insertButton_clicked();	
	void deleteButton_clicked();	
	void saveButton_clicked();	
	void sliderValueChanged(int);

	//from card
	void cardPressed(int);
private:
	void fillVector();	
	void hideCards();
	void showCards(int);
	QString sqlMaker(QString str);

	QString tableName;
	QString checkedS,checkedA,checkedW;

	QVector<QString> heading,sentence,answer,interference,wordPos;
	Card *cards[MAXCARD];
	EditableCard *editableCards[MAXCARD];
	QVBoxLayout *cardListLayout;

	QString dbNameRemain;
	int runMode = 0;
	int activeCard = 0;
	int cardSum = 0;
	int thisPageBegin = 0,nextPageBegin = 0,previousPageBegin = 0;
	int cardsThisPage = 0,cardsNextPage = 0;
};

#endif
